package com.spc.car.web.controller.std;

import com.spc.car.service.standard.OrgTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Pattern;


@Validated
@RequestMapping("/standard")
@Api(tags = "标准")
@RestController
public class StandardController {

    @Autowired
    private OrgTypeService orgTypeService;

    @ApiOperation(value = "查询机构类型信息", notes = "查询机构类型信息")
    @PostMapping("/listOrgType")
    public ResponseEntity listOrgType(@Pattern (regexp = "[0-9]{0,10}")
                                @RequestParam(value = "parentCode" ,required = false) String parentCode) {

        return new ResponseEntity(orgTypeService.listSubType(parentCode), HttpStatus.OK);
    }
}
